﻿
@{
    ViewBag.Title = "角色编辑";
}
@section Css{

   
}
<div class="col-sm-6" style="padding-top: 10px;">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <form class="form-horizontal m-t" id="form1">
                <div class="form-group">
                    <label class="col-sm-3 control-label">角色名：</label>
                    <div class="col-sm-8">
                        <input id="roleName" name="roleName" minlength="2" type="text" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3 text-center">
                        <button id="btn_Submit" class="btn btn-primary" type="button">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@section Js{
    <script type="text/javascript">
        model = @MvcHtmlString.Create(ViewBag.Json);
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        var validator = $("#form1").validate({
            rules: {
                roleName: {
                    required: true
                }
            },
            messages: {
                roleName: {
                    required: "请输入角色名"
                }
            }
        });
        $(function() {
            //dataInit();
            $("#btn_Submit").click(function() {
                if (validator.form()) {
                    var parms = {
                        roleId: model.roleId,
                        roleName: $.trim($("#roleName").val())
                    }
                    $.post("/Account/RoleSave", parms, function(json) {
                        if (json.result == "success") {
                            layer.msg(json.msg, { icon: 1, time: 2000 }, function(data) {
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(json.msg, { icon: 5 , time: 2000});
                        }
                    }, "json");
                }
            });

        });

    </script>
}